package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.AlertData;
import com.zzyl.vo.AlertDataVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface AlertDataMapper {
    int deleteByPrimaryKey(Long id);

    int insert(AlertData record);

    int insertSelective(AlertData record);

    AlertData selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(AlertData record);

    int updateByPrimaryKey(AlertData record);

    /**
     * 这是Mybatis Generator拓展插件生成的方法(请勿删除).
     * This method corresponds to the database table alert_data
     *
     * @mbg.generated
     * @author hewei
     */
    int batchInsert(@Param("list") List<AlertData> list);

    /**
     * 分页查询报警数据
     * @param userId
     * @param deviceName
     * @param startTime
     * @param endTime
     * @return
     */
    /*Page<AlertDataVo> adminpageQuery(
            @Param("id") Long id,
            @Param("status") Integer status,
            @Param("userId") Long userId,
            @Param("deviceName") String deviceName,
            @Param("startTime") LocalDateTime startTime,
            @Param("endTime") LocalDateTime endTime); */
    Page<AlertDataVo> adminpageQuery(
            @Param("userId") Long userId,
            @Param("deviceName") String deviceName,
            @Param("startTime") LocalDateTime startTime,
            @Param("endTime") LocalDateTime endTime);

    /**
     * 处理设备报警数据
     * @param id
     * @param processingResult
     * @param processingTime
     * @param processorName
     * @param id1
     * @param iotId
     */
    void handleAlertData(
            @Param("id") Long id,
            @Param("processingResult") String processingResult,
            @Param("processingTime") LocalDateTime processingTime,
            @Param("processorName") String processorName,
            @Param("id1") Long id1,
            @Param("iotId") String iotId);


    /**
     * 处理相同设备其他待处理报警数据
     * @param iotId
     * @param userId
     * @param realName
     * @param processingResult
     * @param processingTime
     */
    void updateStatusId(@Param("iotId") String iotId,
                      @Param("userId")  Long userId,
                      @Param("realName")  String realName,
                      @Param("processingResult") String processingResult,
                      @Param("processingTime") LocalDateTime processingTime);



    /**
     * 处理设备报警数据
     * @param alertRuleId
     * @param processingResult
     * @param processorId
     * @param processorName
     * @param processingTime
     */
    void updateHandleAlertData(
            @Param("id") Long id,
            @Param("alertRuleId") Long alertRuleId,
            @Param("processingResult") String processingResult,
            @Param("processorId") Long processorId,
            @Param("processorName") String processorName,
            @Param("processingTime") LocalDateTime processingTime);

    /**
     * 处理相同设备其他待处理报警数据
     * @param alertRuleId
     * @param processingResult
     * @param processorId
     * @param processorName
     * @param processingTime
     */
    void updateStatus(
            @Param("alertRuleId") Long alertRuleId,
            @Param("processingResult") String processingResult,
            @Param("processorId") Long processorId,
            @Param("processorName") String processorName,
            @Param("processingTime") LocalDateTime processingTime);
}